<?php
include('connection.php');
include('thuvien.php');
class KhachHang
{
var $MaKH;
var $TenKH;
var $DiaChi;
var $SoDT;
var $Email;
public function InfoKhachHang($MaKH,$TenKH,$DiaChi,$SoDT,$Email)
{
$this->MaKH=$MaKH;
$this->TenKH=$TenKH;
$this->DiaChi=$DiaChi;
$this->SoDT=$SoDT;
$this->Email=$Email;
}
public function GetAll_KhachHang()
{
$sql ="Select  * From KhachHang";
$kq=@mysql_query($sql) or die (@mysql_error());
return $kq;
}
public function Add_KhachHang($TenKH,$DiaChi,$SoDT,$Email)
{
$sql ="INSERT INTO KhachHang ( `TenKH`, `DiaChi`, `SoDT`, `Email`) VALUES ('$TenKH','$DiaChi','$SoDT','$Email')";
$kq=@mysql_query($sql) or die (@mysql_error());
}
public function Update_KhachHang($MaKH,$TenKH,$DiaChi,$SoDT,$Email)
{
$sql ="Update KhachHang Set `TenKH`='$TenKH',`DiaChi`='$DiaChi',`SoDT`='$SoDT',`Email`='$Email'Where MaKH=$MaKH";
$kq=@mysql_query($sql) or die (@mysql_error());
return $kq;
}
public function Delete_KhachHang($id)
{
$sql="Delete from KhachHang Where MaKH=$id  LIMIT 1";
$kq=@mysql_query($sql) or die (@mysql_error());
return $kq;
}
public function ById($id)
{
$sql ="Select  * From KhachHang Where MaKH=$id";
$kq=@mysql_query($sql) or die (@mysql_error());
return $kq;
}

var $pindex;
var $totalp;

public function get_by_page($psize, $pindex, $where = '', $orderby = '')
{
	$this->pindex = $pindex;
	return get_page($psize, $pindex, $this->totalp, 'KhachHang', $where = "",$orderby = "");
}
public function print_page()
{
	return print_page($this->totalp, $this->pindex);
}
}
?>